local skynet = require("skynet")
local s = require("service")

s.client={}

s.gate=nil
s.init =function (  )
    skynet.error("[agent] start ")
    skynet.sleep(200)
    s.data={
        coin=100,
        hp=200,
    }
end
s.client.work=function ( msg )
    skynet.error("[agent] work start")
    skynet.error("before work coin is :"..s.data.coin)
    s.data.coin=s.data.coin +1
    skynet.error("after work coin is :"..s.data.coin)
    return{"work",s.data.coin}
end
s.resp.client=function ( source,cmd,msg )
    s.gate=source
    skynet.error("s.resp.client get source is :"..source)
    skynet.error("s.resp.client get cmd is :"..cmd)
    skynet.error("s.resp.client get msg is :"..table.concat( msg,","))
    if s.client[cmd] then
        local ret_msg = s.client[cmd](msg,source)
        if ret_msg then
            skynet.send(source,"lua","send",s.id,ret_msg)
        end
    else
        skynet.error("s.resp.client fail",cmd)
    end
end
s.resp.kick=function ( source )
    skynet.sleep(200)
end
s.resp.exit=function ( source )
    skynet.exit()
end



s.start(...)